
#ifndef TERRAINTEXTURE_H
#define TERRAINTEXTURE_H

#include <cmath>
#include <windows.h>
#include "gl.h"
#include "glu.h"

#include <iostream>
using namespace std;

#define getRandF() ( rand()/(float)RAND_MAX )
#define getRandIRange(lo,hi) ( ( rand()%((hi)-(lo)+1) ) + (lo) )
#define getRandFRange(lo,hi) ( getRandF()*((hi)-(lo)) + (lo) )

class TerrainTexture {

	public:

		TerrainTexture();
		unsigned int getTextureId();

	private:

		unsigned int uiTexId;
		int iWidth;
		int iHeight;
		float** fElevData;
		float fElevMax;
		float fElevMin;

		void generate();
		void bubble(float h, float radf);
		void polarize();
		void normalize();
		void blendOutPoles();

		inline int getWrappedU(int& u);
		inline int getWrappedV(int& v);

};

#endif